package com.lanyeo.liver.util

import android.graphics.Bitmap

class NCNN {
    private var ncnnObject = 0L
    fun createInstance(bundlePath: String): Boolean {
        ncnnObject = resourceTaskCreate(bundlePath)
        return ncnnObject != 0L
    }

    fun detect(image: Bitmap, objects: ArrayList<Object>): Int {
        return resourceTaskDetect(ncnnObject, image, objects)
    }

    fun destroy() {
        resourceTaskDestroy(ncnnObject)
    }

    external fun resourceTaskCreate(modelDir:String): Long
    external fun resourceTaskDetect(taskObjAddress: Long, image: Bitmap, objects: ArrayList<Object>): Int
    external fun resourceTaskDestroy(taskObjAddress: Long)
    init {
        System.loadLibrary("liver")
    }
}